/*
  OLED显示汉字
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET     4
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

//取16x16汉字字模 逐行式 顺向高位在前
static const unsigned char PROGMEM str1[] =
{
  0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x3F, 0xF8, 0x21, 0x08, 0x21, 0x08, 0x21, 0x08,
  0x21, 0x08, 0x21, 0x08, 0x3F, 0xF8, 0x21, 0x08, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00
};/*"中",0*/

static const unsigned char PROGMEM str2[] =
{
  0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x08, 0x20, 0x08, 0x20,
  0x04, 0x40, 0x02, 0x80, 0x01, 0x00, 0x02, 0x80, 0x04, 0x40, 0x08, 0x20, 0x30, 0x18, 0xC0, 0x06
};/*"文",1*/
static const unsigned char PROGMEM str3[] =
{
  0x00, 0x00, 0x1F, 0xF0, 0x10, 0x10, 0x10, 0x10, 0x1F, 0xF0, 0x10, 0x10, 0x10, 0x10, 0x1F, 0xF0,
  0x04, 0x40, 0x44, 0x44, 0x24, 0x44, 0x14, 0x48, 0x14, 0x50, 0x04, 0x40, 0xFF, 0xFE, 0x00, 0x00
};/*"显",2*/

static const unsigned char PROGMEM str4[] =
{
  0x00, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x01, 0x00,
  0x01, 0x00, 0x11, 0x10, 0x11, 0x08, 0x21, 0x04, 0x41, 0x02, 0x81, 0x02, 0x05, 0x00, 0x02, 0x00
};/*"示",3*/

//32x32汉字取模数据
static const unsigned char PROGMEM str5[] =
{
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
  0x08, 0x01, 0x80, 0x20, 0x0F, 0xFF, 0xFF, 0xF0, 0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x20,
  0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x20, 0x0F, 0xFF, 0xFF, 0xE0, 0x0C, 0x01, 0x80, 0x20, 0x0C, 0x01, 0x80, 0x30, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
  0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"中",0*/
};/*"中",0*/
static const unsigned char PROGMEM str6[] =
{
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x80, 0x38,
  0x3F, 0xFF, 0xFF, 0xFC, 0x00, 0x20, 0x0C, 0x00, 0x00, 0x20, 0x0C, 0x00, 0x00, 0x20, 0x0C, 0x00, 0x00, 0x10, 0x0C, 0x00, 0x00, 0x10, 0x18, 0x00, 0x00, 0x10, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
  0x00, 0x08, 0x30, 0x00, 0x00, 0x0C, 0x30, 0x00, 0x00, 0x04, 0x60, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x02, 0xC0, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0xC0, 0x00,
  0x00, 0x06, 0xE0, 0x00, 0x00, 0x0C, 0x78, 0x00, 0x00, 0x38, 0x1E, 0x00, 0x00, 0x60, 0x0F, 0xC0, 0x01, 0x80, 0x03, 0xFC, 0x0E, 0x00, 0x00, 0xF0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"文",1*/
};/*"文",1*/



void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextColor(WHITE);//开像素点发光
  display.clearDisplay();//清屏

  display.setTextSize(1); //设置字体大小
  display.setCursor(35, 5);//设置显示位置
  display.println("-TonyCode-");//输出字符

//    display.drawBitmap(32, 32, str1, 16, 16, 1); //画出字符对应点阵数据
//    display.drawBitmap(48, 32, str2, 16, 16, 1); //画出字符对应点阵数据
//    display.drawBitmap(64, 32, str3, 16, 16, 1); //画出字符对应点阵数据
//    display.drawBitmap(80, 32, str4, 16, 16, 1); //画出字符对应点阵数据

  display.drawBitmap(32, 32, str5, 32, 32, 1); //画出字符对应点阵数据
  display.drawBitmap(64, 32, str6, 32, 32, 1); //画出字符对应点阵数据
  display.display();//开显示

}

void loop() {

}
